using System;
using System.Collections.Generic;
using System.Text;

namespace XiaoGang.Soft.XGWMS.UI.Controls
{
    public class XGSOFTDataGrid : System.Windows.Forms.DataGridView
    {
        public XGSOFTDataGrid()
        {
            //this.Rows.Count= 1;
        }

        private string m_strGridColTitle = string.Empty;
        private string m_strGridColWidth = string.Empty;
        private string m_strGridColNames = string.Empty;

        /// <summary>
        /// SetGridColWidth
        /// </summary>
        private void SetGridColWidth()
        {
            try
            {
                string[] strGridColWidthArray = m_strGridColWidth.Split(',');
                //this.Columns.Count = strGridColWidthArray.Length;
                for (int i = 0; i < strGridColWidthArray.Length; i++)
                {
                    this.Columns[i].Width = Convert.ToInt32(strGridColWidthArray[i].Trim());
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteClientErrLog4Net(ex);
            }
        }

        /// <summary>
        /// CustGridColWidth
        /// </summary>
        public string CustGridColWidth
        {
            get { return m_strGridColWidth; }
            set
            {
                m_strGridColWidth = value;
                if (value.Trim() != string.Empty)
                {
                    SetGridColWidth();
                }
            }
        }

        /// <summary>
        /// SetGridColTitle
        /// </summary>
        private void SetGridColTitle()
        {
            try
            {
                string[] strGridColTitleArray = m_strGridColTitle.Split(',');
                //this.Columns.Count = strGridColTitleArray.Length;
                for (int i = 0; i < strGridColTitleArray.Length; i++)
                {
                    this.Columns[i].HeaderText = strGridColTitleArray[i].Trim();
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteClientErrLog4Net(ex);
            }
        }

        /// <summary>
        /// CustGridColTitle
        /// </summary>
        public string CustGridColTitle
        {
            get { return m_strGridColTitle; }
            set
            {
                m_strGridColTitle = value;
                if (value.Trim() != string.Empty)
                {
                    SetGridColTitle();
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        private void SetGridColNames()
        {
            try
            {
                string[] strGridColNamesArray = m_strGridColNames.Split(',');
                //this.Columns.Count = strGridColNamesArray.Length;
                for (int i = 0; i < strGridColNamesArray.Length; i++)
                {
                    this.Columns[i].Name = strGridColNamesArray[i].Trim();
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteClientErrLog4Net(ex);
            }
        }

        /// <summary>
        /// CustGridColNames
        /// </summary>
        public string CustGridColNames
        {
            get { return m_strGridColNames; }
            set
            {
                m_strGridColNames = value;
                if (value.Trim() != string.Empty)
                {
                    SetGridColNames();
                }
            }
        }
    }
}
